#import "WBView.h"
#import "Prefs.h"

@implementation WBView

@synthesize barLength;

- (void) awakeFromNib {	
	[[self window] setCanHide:NO];
    //load the images we'll use from the bundle's Resources directory
    face = [NSImage imageNamed:@"WorkBreak"];
	barLength = 0;
}

- (void) drawRect:(NSRect)rect
{	
	
    [[NSColor clearColor] set];
    NSRectFill([self frame]);	
	
	[face compositeToPoint:NSZeroPoint operation:NSCompositeSourceOver];
	
	// begin to draw the progress bar
	[[NSColor whiteColor] set];
	
	CGFloat totalBarLength = rect.size.width - 20;
	NSPoint barLeft = NSMakePoint(10, 50);
	NSPoint barRight = NSMakePoint(10 + totalBarLength - totalBarLength*(barLength/INDICATOR_STEP), 50);
	NSBezierPath *path = [NSBezierPath bezierPath];
	[path setLineWidth:BAR_WIDTH];
	[path moveToPoint:barLeft];
	[path lineToPoint:barRight];
	[path stroke];
	// finished
	
    if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_1)
    {
        [[self window] setHasShadow:NO];
        [[self window] setHasShadow:YES];
    }
    else
        [[self window] invalidateShadow];
	
	[[self window] setAlphaValue:0.95];	
}

- (void) dealloc {
	[super dealloc];
}

@end
